package site.marqstree.elecommerce.app;

import android.webkit.WebView;
import android.widget.Toast;

import site.marqstree.latte.core.delegates.web.event.Event;

/*
 * 项目名: EleCommerce
 * 包名: site.marqstree.latte.core.delegates.web.event
 * 文件名: TestEvent
 * 创建者: marqstree
 * 创建时间: 2020/1/31 17:07
 * 描述: TODO
 */
public class TestEvent extends Event {
    @Override
    public String execute(String params) {
        //Toast.makeText(getContext(), getAction(), Toast.LENGTH_LONG).show();
        if (getAction().equals("test")) {
            final WebView webView = getWebView();
            //post:采用UI线程执行
            webView.post(new Runnable() {
                @Override
                public void run() {
                    //webView.evaluateJavascript("javascript:nativeCall();", null);
                    //webView.loadUrl("javascript:nativeCall();");
                    webView.loadUrl("javascript:alert('haha');");
                }
            });
        }
        return null;
    }
}
